<?php
/**
 * Created by PhpStorm.
 * User: alei
 * Date: 11/5/2017 AD
 * Time: 16:58
 */
namespace App\Models\Mysql;

//use Illuminate\Database\Eloquent\Model;
use App\Models\Traits\BaseDBMethod;

class pre_ucenter_members
{
	use BaseDBMethod;
	//数据库连接配置项，见config/database.php
	const DATABASE_CONF = 'lqyw_mysql';
	//pre_ct_ui 首页轮播图所在表
	const TABLE_NAME = 'pre_ucenter_members';

	//数据库连接配置项，见config/database.php
	//如果需要用ORM，需要设置此项
//	protected $connection = self::DATABASE_CONF;
	//表名，如果需要用ORM，需要设置此项
//	protected $table = self::TABLE_NAME;



    public static function check($param)
    {

        $r=self::getConnObj()->select(
            "SELECT * FROM pre_ucenter_members  WHERE username=:username ",
            [
                'username' => $param['username'],
            ]
        );
        if($r)
        {
            $pass=$r[0]->salt;
            $md5=md5(md5($param['password']).$pass);
            $data=self::getConnObj()->select(
                "SELECT uid,username userName FROM pre_ucenter_members  WHERE password=:password and  username=:username ",
                [
                    'password' => $md5,
                    'username' => $param['username'],
                ]
            );
            if($data)
            {
                return array($data,'Success');
            }
			else{
				return array(false,'PasswordNotCorrect');
			}
        }
		else{
			return array(false,'UserNotExist');
		}
    }



}